package com.ferry.wallpaper.controller;

import com.ferry.wallpaper.utils.RandomArtUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpSession;

@Controller
public class IndexController {

    @GetMapping("/")
    public String index(Model model, HttpSession session) {
        if (session.getAttribute("user") == null) {
            session.setAttribute("say",false);
            session.setAttribute("add",true);
        } else {
            session.setAttribute("say",true);
            session.setAttribute("add",false);
        }
        model.addAttribute("sayer", RandomArtUtils.getRandom());
        return "index";
    }

}
